/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - system/io
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AESearchPath.h
// Author:		Gianluca Belardelli
// Date:		10/10/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AESEARCHPATH_H_
#define _AESEARCHPATH_H_

/// \brief
///   Represents a single search path.
///
/// Search paths are a layer above file systems within the VFileAccessManager. They are expressed as
/// platform independent paths, and provide the base paths against which the VFileAccessManager tries
/// to resolve relative paths. Each search paths may also be the root of an asset library, in which case
/// an asset look-up table will be loaded and asset redirections may be performed as part of the path
/// resolution process.
///
/// Instances of this class are only created by the VFileAccessManager.
class AESearchPath : public AEReferencedObject
{
	friend class AEFileManager;
// Members
private:
	AEBOOL32	m_bWritable;
	char		*m_lpBasePath;
	char		*m_lpRootName;
	const char	*m_lpPathBelowRoot;

// Methods
private:
	/// \brief
	///   Constructor; initializes a new VSearchPath.
	/// \param owner
	///   the VFileAccessManager that owns this search path object
	/// \param szBasePath
	///   the platform-independent, absolute base path
	/// \param bWritable
	///   whether this search path allows writing. Note that if the search path is to be writable, 
	///   the underlying file system must be writable as well.
	AESearchPath( const char *lpBasePath, AEBOOL32 bWritable = 0 );
	AESearchPath( const AESearchPath& );
	AESearchPath &operator=( const AESearchPath& );

public:
	virtual ~AESearchPath( void );

	/// \brief
	///   Returns whether this search path is writable.
	AE_FORCEINLINE AEBOOL32 IsWritable( void ) const { return m_bWritable; }

	/// \brief
	///   Returns the base path of this search path.
	AE_FORCEINLINE const char *GetBasePath( void ) const { return m_lpBasePath; }

	/// \brief
	///   Returns the root part of the base path.
	AE_FORCEINLINE const char *GetRootName( void ) const { return m_lpRootName; }

	/// \brief
	///   Returns the part of the base path below the root component.
	AE_FORCEINLINE const char *GetPathBelowRoot( void ) const { return m_lpPathBelowRoot; }
};

#endif // _AESEARCHPATH_H_
